#include <iostream>
#include "tree_structures.h"

#include <queue>
#include <stack>

#define INDEXID 0
#define LEAFID 1

using namespace std;

class Index {

const int d;
Node * root;
queue<Node *> queue;
stack<stackElement *> stack;
stackElement * stackFirst;

//Index Print Helper Functions
void printKeysNode(Node *);
void printLevel();
void resetQueue();

//Index Structure Helper Functions
bool isNodeFull(Node *node);
void insertRecordInLeaf(LeafNode *,int, Record *);
IndexNode * splitLeafNode(LeafNode*);
IndexNode * splitIndexNode(IndexNode *);
void addNodesToQueue(IndexNode *);
void insertKeyInIndex(IndexNode *, IndexNode *, int );
void resetStack();
Record * returnRecordInLeaf(int, LeafNode *);

public:

Index(int d): d(d) {
	root = new LeafNode(d);
	stackFirst = new stackElement();
	stackFirst->node = root;
	stackFirst->index = 0;
	stack.push(stackFirst);
	queue.push(root);
}

Index(): d(64) {
	root = new LeafNode(64);
	stackFirst = new stackElement();
	stackFirst->node = root;
	stackFirst->index = 0;
	stack.push(stackFirst);
	queue.push(root);
}

void printKeys();
void printIndex();
Record *searchRecord(int searchKey);
void insertRecord(int, Record *);

};

